import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';

@Entity('customer_info',{database:'daijia_customer'}) // 指定数据库表名
export class CustomerInfo {
  @ApiProperty({ description: '用户ID', example: 1 })
  @PrimaryGeneratedColumn({ type: 'bigint', name: 'id' , comment: '用户ID' })
  id: number;

  @ApiProperty({ description: '微信OpenID', example: 'wx1234567890abcdef' })
  @Column({ type: 'varchar', length: 200, nullable: false, unique: true, comment: '微信OpenID' })
  wx_open_id: string;

  @ApiProperty({ description: '昵称', example: '张三', required: false })
  @Column({ type: 'varchar', length: 200, nullable: true, comment: '昵称' })
  nickname: string;

  @ApiProperty({ description: '性别：1-男，2-女', example: '1', required: true })
  @Column({ type: 'char', length: 1, nullable: false, default: '1', comment: '性别：1-男，2-女' })
  gender: string;

  @ApiProperty({ description: '头像URL', example: 'http://example.com/avatar.jpg', required: false })
  @Column({ type: 'varchar', length: 200, nullable: true, comment: '头像URL' })
  avatar_url: string;

  @ApiProperty({ description: '电话号码', example: '12345678901', required: false })
  @Column({ type: 'char', length: 11, nullable: true, comment: '电话号码' })
  phone: string;

  @ApiProperty({ description: '状态：1-启用，0-禁用', example: 1, required: true })
  @Column({ type: 'tinyint', nullable: true, default: 1, comment: '状态：1-启用，0-禁用' })
  status: number;

  @ApiProperty({ description: '创建时间', example: '2023-01-01T00:00:00.000Z' })
  @CreateDateColumn({
    type: 'timestamp',
     comment: '创建时间',
  })
  create_time: Date;

  @ApiProperty({ description: '更新时间', example: '2023-01-01T00:00:00.000Z' })
  @UpdateDateColumn({
    type: 'timestamp',
     // onUpdate: 'CURRENT_TIMESTAMP',
    comment: '更新时间',
  })
  update_time: Date;

  @ApiProperty({ description: '是否删除：0-未删除，1-已删除', example: 0, required: true })
  @Column({ type: 'tinyint', nullable: false, default: 0, comment: '是否删除：0-未删除，1-已删除' })
  is_deleted: number;
}